Skip to content

Conversation

@DSharifi
Copy link
Contributor

Motivation

Resolves #7374

The usage of a DelayQueue often involves using its implementation of StreamExt::next in select! statements, where users need to know whether the method is cancellation safe or not.

DelayQueue's Stream::poll_next implementation which is backed by poll_expired does not maintain any intermediary state with side effects on its internal state when returning Pending, thus StreamExt::next should be cancellation safe.

Solution

Added a note that its implementation is cancellation safe.

@ADD-SP ADD-SP added T-docs Topic: documentation A-tokio-util Area: The tokio-util crate M-time Module: tokio/time labels Aug 31, 2025
Copy link
Member

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me.

Copy link
Member

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ADD-SP ADD-SP changed the title docs: Add cancellation safety note for DelayQueue's StreamExt::next implementation time: clarify the cancellation safety of the DelayQueue Aug 31, 2025
@DSharifi
Copy link
Contributor Author

Thanks for the review! @ADD-SP

@ADD-SP ADD-SP merged commit adc3e19 into tokio-rs:master Aug 31, 2025
90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tokio-util Area: The tokio-util crate M-time Module: tokio/time T-docs Topic: documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document cancellation safety for DelayQueue

2 participants